clc
clear
close all
load('data.mat');
d2r = pi/180;

t1 = PNG(:,1);
x1 = PNG(:,2);
y1 = PNG(:,3);
z1 = PNG(:,4);
V1 = PNG(:,5);
fpa1 = PNG(:,6)/d2r;
azi1 = PNG(:,7)/d2r;
lambda1 = PNG(:,8)/d2r;
phi1 = PNG(:,9)/d2r;
tPNG1 = PNG(:,10);
alpha1 = PNG(:,11)/d2r;
bank1 = PNG(:,12)/d2r;
et1 = PNG(:,13);
r1 = PNG(:,14);
dr1 = PNG(:,15);
delta1 = PNG(:,16)/d2r;
eta1 = PNG(:,17)/d2r;

t2 = ITCG1(:,1);
x2 = ITCG1(:,2);
y2 = ITCG1(:,3);
z2 = ITCG1(:,4);
V2 = ITCG1(:,5);
fpa2 = ITCG1(:,6)/d2r;
azi2 = ITCG1(:,7)/d2r;
lambda2 = ITCG1(:,8)/d2r;
phi2 = ITCG1(:,9)/d2r;
tPNG2 = ITCG1(:,10);
alpha2 = ITCG1(:,11)/d2r;
bank2 = ITCG1(:,12)/d2r;
et2 = ITCG1(:,13);
r2 = ITCG1(:,14);
dr2 = ITCG1(:,15);
delta2 = ITCG1(:,16)/d2r;
eta2 = ITCG1(:,17)/d2r;

f = figure('Name', '飞行轨迹的铅锤投影');
plot(x1/1e3,z1/1e3,':', x2/1e3,z2/1e3, '--', 'LineWidth',2);
xlabel('x/km');ylabel('z/km');
legend('PNG','ITCG','Location','northwest');
saveas(f, f.Name, 'svg')

f = figure('Name', '飞行轨迹的水平投影');
plot(x1/1e3,y1/1e3,':', x2/1e3,y2/1e3, '--','LineWidth',2);
xlabel('x/km');ylabel('y/km');
legend('PNG','ITCG')
saveas(f, f.Name, 'svg')

f = figure('Name', 'speed');
plot(t1, V1, ':', t2, V2, '--','LineWidth',2);
xlabel('时间（s）'); ylabel("速度（m/s）");
legend('PNG','ITCG')
saveas(f, f.Name, 'svg')

f = figure('Name', 'flight path angle');
plot(t1,fpa1,':', t2,fpa2, '--','LineWidth',2);
xlabel('时间（s）'); ylabel("弹道倾角(deg)");
legend('PNG','ITCG')
saveas(f, f.Name, 'svg')

f = figure('Name', 'azimuth angle');
plot(t1, azi1, ':', t2, azi2, '--','LineWidth',2);hold on;
xlabel('时间（s）'); ylabel("弹道偏角(deg)");
legend('PNG','ITCG')
saveas(f, f.Name, 'svg')

f = figure('Name', 'guidance command');
subplot(2,1,1)
plot(t1(2:end), alpha1(2:end),':', t2(2:end), alpha2(2:end), '--','LineWidth',2);
xlabel('时间（s）'); ylabel("攻角（deg）");
legend('PNG','ITCG')
subplot(2,1,2)
plot(t1(2:end), bank1(2:end), ':', t2(2:end), bank2(2:end), '--', 'LineWidth',2);
xlabel('时间（s）'); ylabel("倾侧角（deg）");
saveas(f, f.Name, 'svg')

f = figure('Name', '速度前置角(铅锤平面)');
plot(t1, delta1,':', t2, delta2, '--', 'LineWidth',2);
xlabel('时间（s）'); ylabel("铅锤速度前置角(deg)");
legend('PNG','ITCG')
saveas(f, f.Name, 'svg')

f = figure('Name', '速度前置角(水平面)');
plot(t1, eta1, ':', t2, eta2, '--','LineWidth',2);
xlabel('时间（s）'); ylabel("水平速度前置角(deg)");
legend('PNG','ITCG')
saveas(f, f.Name, 'svg')

f = figure('Name', 'tracking error');
plot(t2, et2, '--', 'LineWidth',2);
xlabel('时间（s）'); ylabel("攻击时间误差（s）");
saveas(f, f.Name, 'svg')